//==================================================================
//  Copyright (C) 2006-2007  Davide Pasca
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Lesser General Public
//  License as published by the Free Software Foundation; either
//  version 2.1 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Lesser General Public License for more details.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with this library; if not, write to the Free Software
//  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//==================================================================
///
///
///
///
///
//==================================================================

#ifndef APPBASE3_H
#define APPBASE3_H

#include <Windows.h>

#include "psys.h"
#include "pwindow.h"
#include "console.h"
#include "font.h"
#include "gfxutils.h"
#include "texture.h"

//==================================================================
extern bool		main_start( void *hinstance );
extern void		main_anim();
extern int		main_requestquit();
extern void		main_quit();

//==================================================================
class Application
{
	HACCEL				_hAccelTable;
	std::vector<HWND>	_modeless_list;

public:
	Application() :
	  _hAccelTable(NULL)
	{
	}

	virtual bool Idle();
	virtual bool NeedQuit() const = 0;

	void AddModelessDialog( HWND hwnd );
	void RemoveModelessDialog( HWND hwnd );

};

//==================================================================
void appbase_add_modeless_dialog( void *hwnd );
void appbase_rem_modeless_dialog( const void *hwnd );

//==================================================================
int appbase_filerequest_open( Window *winp, 
                       TCHAR *out_pathnamep, int sizeof_pathname,
                       TCHAR *out_filenamep, int sizeof_filename,
                       int *io_fileindexp,
                       const TCHAR *filterp );

int appbase_filerequest_save( Window *winp, 
                       TCHAR *out_pathnamep, int sizeof_pathname,
                       TCHAR *out_filenamep, int sizeof_filename,
                       int *io_fileindexp,
                       const TCHAR *filterp, const TCHAR *defextp );

void appbase_window_title_set( const TCHAR *titlep );

int appbase_mainloop();

/*
********************************************************************
                           TEMPLATE
********************************************************************

//==================================================================
//==
//==
//==
//==================================================================

#include "appbase.h"

//==================================================================
char   _appbase_window_title[] = "";
char   _appbase_window_class[] = "_CLASS";

//==================================================================
int   main_eventfilter( void *userobjp, WindowEvent *eventp )
{
   //cons_parent_eventfilter( userobjp, eventp );

   switch ( eventp->GetType() )
   {
   case WindowEvent::ETYPE_CREATE:
      // init( eventp->winp );
      break;

   case WindowEvent::ETYPE_PAINT:
      //render();
      break;

   case WindowEvent::ETYPE_WINRESIZE:
      glViewport( 0, 0, eventp->win_w, eventp->win_h );
      break;

   case WindowEvent::ETYPE_KEYDOWN:
      //if ( eventp->keycode == VK_ESCAPE ) {}
      break;

   case WindowEvent::ETYPE_KEYCHAR:
      // if ( eventp->keychar == '/' )   {}
      break;

   case WindowEvent::ETYPE_MOUSEMOVE:
      // eventp->mouse_x, eventp->mouse_y
      break;
   }

   return 0;
}

//==================================================================
void main_anim(void)
{
}

//==================================================================
int   main_requestquit(void)
{
   return 0;
}

//==================================================================
void main_quit(void)
{
}
*/

#endif
